package com.mars.module.admin.controller;


import java.util.Arrays;
import com.mars.common.enums.BusinessType;
import com.mars.common.result.R;
import io.swagger.annotations.Api;
import com.mars.module.admin.entity.Aaaa;
import com.mars.framework.annotation.Log;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import com.mars.common.response.PageInfo;
import org.springframework.web.bind.annotation.*;
import lombok.extern.slf4j.Slf4j;
import com.mars.module.admin.service.IAaaaService;
import com.mars.module.admin.request.AaaaRequest;

/**
 * 啊啊啊啊控制层
 *
 * @author zhangzheng
 * @date 2024-01-07
 */
@Slf4j
@AllArgsConstructor
@RestController
@Api(value = "啊啊啊啊接口管理",tags = "啊啊啊啊接口管理")
@RequestMapping("/admin/aaaa" )
public class AaaaController {

    private final IAaaaService iAaaaService;

    /**
     * 分页查询啊啊啊啊列表
     */
    @ApiOperation(value = "分页查询啊啊啊啊列表")
    @PostMapping("/pageList")
    public R<PageInfo<Aaaa>> pageList(@RequestBody AaaaRequest aaaa) {
        return R.success(iAaaaService.pageList(aaaa));
    }

    /**
     * 获取啊啊啊啊详细信息
     */
    @ApiOperation(value = "获取啊啊啊啊详细信息")
    @GetMapping(value = "/query/{id}")
    public R<Aaaa> detail(@PathVariable("id") Long id) {
        return R.success(iAaaaService.getById(id));
    }

    /**
     * 新增啊啊啊啊
     */
    @Log(title = "新增啊啊啊啊", businessType = BusinessType.INSERT)
    @ApiOperation(value = "新增啊啊啊啊")
    @PostMapping("/add")
    public R<Void> add(@RequestBody AaaaRequest aaaa) {
        iAaaaService.add(aaaa);
        return R.success();
    }

    /**
     * 修改啊啊啊啊
     */
    @Log(title = "修改啊啊啊啊", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改啊啊啊啊")
    @PostMapping("/update")
    public R<Void> edit(@RequestBody AaaaRequest aaaa) {
        iAaaaService.update(aaaa);
        return R.success();
    }

    /**
     * 删除啊啊啊啊
     */
    @Log(title = "删除啊啊啊啊", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除啊啊啊啊")
    @PostMapping("/delete/{ids}" )
    public R<Void> remove(@PathVariable Long[] ids) {
        iAaaaService.deleteBatch(Arrays.asList(ids));
        return R.success();
    }
}
